import VueRouter from 'vue-router'
import { DefaultLayout, NotNavLayout } from '../layouts'


const routes = [
  {
    path: '/',
    component: DefaultLayout,
    children: [
      {
        path: '/',
        name: 'Home',
        component: () => import(/* webpackChunkName: "Home" */'@/views/Home.vue')
      },
      {
        path: '/artical/:id',
        name: 'Artical',
        component: () => import(/* webpackChunkName: "Artical" */'@/views/Artical.vue')
      },
      {
        path: '/search/:searchText',
        name: 'Search',
        component: () => import(/* webpackChunkName: "Search" */'@/views/Search.vue')
      },
    ]
  }, {
    path: '/',
    component: NotNavLayout,
    children: [
      {
        path: '/myself',
        name: 'MySelf',
        component: () => import(/* webpackChunkName: "MySelf" */'@/views/MySelf.vue')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}

export default router
